package cn.hfuu.utils;

import java.util.List;

public class PageBean {
    private List list;
    private Integer totalPage;
    private Integer currentPage;
    private Integer pageSize;
    private Integer totalCount;

    public PageBean(Integer totalCount,Integer currentPage, Integer pageSize) {
        this.currentPage = currentPage;
        this.pageSize = pageSize;
        this.totalCount = totalCount;

        if(this.currentPage==null){
            this.currentPage = 1;
        }
        if(this.pageSize==null){
            this.pageSize = 3;
        }

        this.totalPage = (this.totalCount+this.pageSize-1)/this.pageSize;
        if(this.currentPage<1) {
            this.currentPage=1;
        }
        if(this.currentPage>this.totalPage){
            this.currentPage=this.totalPage;
        }

    }

    //计算起始索引
    public int getStart(){
        return (this.currentPage-1)*this.pageSize;
    }
    public List getList() {
        return list;
    }

    public void setList(List list) {
        this.list = list;
    }

    @Override
    public String toString() {
        return "PageBean{" +
                "list=" + list +
                ", totalPage=" + totalPage +
                ", currentPage=" + currentPage +
                ", pageSize=" + pageSize +
                ", totalCount=" + totalCount +
                '}';
    }

    public Integer getTotalPage() {
        return totalPage;
    }

    public void setTotalPage(Integer totalPage) {
        this.totalPage = totalPage;
    }

    public Integer getCurrentPage() {
        return currentPage;
    }

    public void setCurrentPage(Integer currentPage) {
        this.currentPage = currentPage;
    }

    public Integer getPageSize() {
        return pageSize;
    }

    public void setPageSize(Integer pageSize) {
        this.pageSize = pageSize;
    }

    public Integer getTotalCount() {
        return totalCount;
    }

    public void setTotalCount(Integer totalCount) {
        this.totalCount = totalCount;
    }

}
